const moment = require('moment')
const { v4: uuidv4 } = require('uuid');

module.exports = {
  formatTime(date, format = 'YYYY-MM-DD HH:mm:ss') {
    return moment(date).format(format)
  },
  getUUID() {
    return uuidv4();
  },
  getPageArr(total) {
    const arr = []
    for (let i = 1; i <= Math.ceil(total / 10); i++) {
      arr.push(i)
    }
    return arr
  },
  getChinese(strValue, num = 200) {
    const reg = /[\u4e00-\u9fa5]/g;
    if (strValue !== null && strValue !== '') {
      if (reg.test(strValue)) {
        return strValue.match(reg).join('').slice(0, num);
      } else {
        return strValue;
      }
    }
  }
};